﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using C1.Phone.Chart;
using Microsoft.Phone.Shell;

namespace ControlExplorer.Controls.Chart
{
    public partial class Labels
        : UserControl, IExposeApplicationBarItems
    {
        ApplicationBarIconButton btnColumn = new ApplicationBarIconButton(new Uri("Resources/AppBar/chart_column.png", UriKind.Relative));
        ApplicationBarIconButton btnLine = new ApplicationBarIconButton(new Uri("Resources/AppBar/chart_line.png", UriKind.Relative));
        ApplicationBarIconButton btnPie = new ApplicationBarIconButton(new Uri("Resources/AppBar/chart_pie.png", UriKind.Relative));

        public Labels()
        {
            InitializeComponent();

            btnColumn.Text = "Column";
            btnColumn.Click += btnColumn_Click;
            
            btnLine.Text = "Line";
            btnLine.Click += btnLine_Click;
            
            btnPie.Text = "Pie";
            btnPie.Click += btnPie_Click;

            c1chart.BeginUpdate();
            c1chart.View.AxisY.Min = 0; 
            c1chart.View.AxisY.Max = 10;
            c1chart.Data.LoadAnimation = AnimationHelper.CreateAnimation(AnimationTransform.Scale, AnimationOrigin.Bottom, Easing.CubicEase, true);
            c1chart.EndUpdate();

            btnColumn_Click(null, EventArgs.Empty);
        }


        void btnColumn_Click(object sender, EventArgs e)
        {
            c1chart.ChartType = ChartType.Column;
            btnColumn.IsEnabled = false;
            btnPie.IsEnabled = true;
            btnLine.IsEnabled = true;
        }

        void btnLine_Click(object sender, EventArgs e)
        {
            c1chart.ChartType = ChartType.Line;
            btnColumn.IsEnabled = true;
            btnPie.IsEnabled = true;
            btnLine.IsEnabled = false;            
        }

        void btnPie_Click(object sender, EventArgs e)
        {
            c1chart.ChartType = ChartType.Pie;
            btnColumn.IsEnabled = true;
            btnPie.IsEnabled = false;
            btnLine.IsEnabled = true;
        }


        #region IExposeApplicationBarItems Members

        public IEnumerable<IApplicationBarMenuItem> ApplicationBarItems
        {
            get 
            {
                yield return btnColumn;
                yield return btnLine;
                yield return btnPie;
            }
        }

        #endregion
    }
}